const { SuccessModel, ErrorModel } = require('../../model/responseMode');
const { getMusicList, getMusicItem, addMusicList, updataMusicList} = require('../../controllers/music/musicController')

const musicListRouter = async (req, res) => {
  const {path, query} = req

  if(path == '/api/music/add'){
    let data = await addMusicList();
    return new SuccessModel(data);
  }

  // 更新音乐资源
  if(path == '/api/music/updata'){
    let data = await updataMusicList();
    return new SuccessModel(data);
  }

  // 处理音乐列表
  if(path == '/api/music/list'){
    // console.log(path, query)
    return data = await getMusicList(query);
    // return new SuccessModel(data);
  }

  // 获取单个音乐文件
  if(path == '/api/get/music'){
    return data = await getMusicItem(query);
    // if(data.code == 4000){
    //   return data
    // }
    // return new SuccessModel(data);
  }
}

module.exports = musicListRouter;